package com.jjlin.chapter_1;

import java.util.*;
public class CD13 {

    public static void sortStackByStack(Stack<Integer> stack){
        Stack<Integer> help = new Stack<>();
        help.push(stack.pop());
        while(!stack.isEmpty()){
            int cur = stack.pop();
            while(!help.isEmpty() && cur > help.peek()){
                stack.push(help.pop());
            }
            help.push(cur);
        }
        while(!help.isEmpty())
            stack.push(help.pop());
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Stack<Integer> stack = new Stack<>();
        for(int i = 0; i < n; i++)
            stack.push(sc.nextInt());
        sortStackByStack(stack);
        while(!stack.isEmpty())
            System.out.print(stack.pop() + " ");
    }
}
